package com.itheima.dubbo.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Value;

@DubboService      //标识服务提供方
//@DubboService(timeout = 2000)//提供方接口超时时间
//@DubboService(methods = {
//        @Method(name = "getById",timeout = 2000)
//})//提供者方法超时时间
//@DubboService(retries = 1)//设置重试次数
//@DubboService(methods = {
//        @Method(name = "getById",retries = 0)
//})//给方法设置重试次数
//@DubboService(version = "#{dubbo.application.version}")//灰度发布(多版本)
public class UserServiceImpl implements UserFace{
    @Override
    public String hell(String username) {
        System.out.println("乌拉");

        return "姓名"+username;
    }

    @Value("${service.port}")
    private Integer port;
    @Override
    public User getById(Long id) {
        User userReult = new User(id,"胡浩楠",22);

        String name = RpcContext.getContext().getAttachment("name");
        System.out.println(name+port);
//        try {
//            Thread.sleep(4000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        return userReult;
    }
}
